VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MsComCtl.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmAPPettyCashAd 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   6360
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   9150
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6360
   ScaleWidth      =   9150
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   15
      Top             =   6075
      Width           =   9150
      _ExtentX        =   16140
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   2912
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   2715
      Left            =   0
      Top             =   3240
      Width           =   9030
      _ExtentX        =   15928
      _ExtentY        =   4789
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin MSDataGridLib.DataGrid dtgJE 
         Height          =   2295
         Left            =   0
         TabIndex        =   13
         Top             =   420
         Width           =   9030
         _ExtentX        =   15928
         _ExtentY        =   4048
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   5
         BeginProperty Column00 
            DataField       =   "cAcctNo"
            Caption         =   "Account No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cTitle"
            Caption         =   "Title"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "nDebit"
            Caption         =   "Debit"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "nCredit"
            Caption         =   "Credit"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1395.213
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   2310.236
            EndProperty
            BeginProperty Column02 
               ColumnWidth     =   1425.26
            EndProperty
            BeginProperty Column03 
               ColumnWidth     =   1230.236
            EndProperty
            BeginProperty Column04 
               ColumnWidth     =   2520
            EndProperty
         EndProperty
      End
   End
   Begin ITGControls.ITGTab SSTab1 
      Height          =   5955
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   9030
      _ExtentX        =   15928
      _ExtentY        =   10504
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   16243138
      DisabledTabForeColor=   -2147483627
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   2940
         Left            =   -75000
         TabIndex        =   14
         Top             =   315
         Width           =   9030
         _ExtentX        =   15928
         _ExtentY        =   5186
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   5
         BeginProperty Column00 
            DataField       =   "cPRNo"
            Caption         =   "PCV No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Name"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cType"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cDept"
            Caption         =   "Posted"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   ""
            Caption         =   "Closed"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               ColumnAllowSizing=   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1349.858
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   2670.236
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1425.26
            EndProperty
            BeginProperty Column03 
               ColumnWidth     =   1260.284
            EndProperty
            BeginProperty Column04 
               ColumnWidth     =   1214.929
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   2940
         Left            =   0
         Top             =   315
         Width           =   9030
         _ExtentX        =   15928
         _ExtentY        =   5186
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Petty Cash Advance Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   2580
            Top             =   600
         End
         Begin VB.CommandButton cmdPickEmpCode 
            Height          =   300
            Left            =   2955
            Picture         =   "frmAPPettyCashAd.frx":0000
            Style           =   1  'Graphical
            TabIndex        =   5
            Top             =   915
            Width           =   315
         End
         Begin VB.CommandButton cmdPickDeptID 
            Height          =   300
            Left            =   2955
            Picture         =   "frmAPPettyCashAd.frx":014A
            Style           =   1  'Graphical
            TabIndex        =   8
            Top             =   1230
            Width           =   315
         End
         Begin VB.ComboBox cboType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmAPPettyCashAd.frx":0294
            Left            =   6180
            List            =   "frmAPPettyCashAd.frx":029E
            Style           =   2  'Dropdown List
            TabIndex        =   3
            Top             =   585
            Width           =   1425
         End
         Begin VB.CommandButton cmdPickTripTicket 
            Height          =   300
            Left            =   2955
            Picture         =   "frmAPPettyCashAd.frx":02AF
            Style           =   1  'Graphical
            TabIndex        =   11
            Top             =   1545
            Width           =   315
         End
         Begin ITGControls.ITGTextBox txtPettyCashAd 
            Height          =   285
            Left            =   120
            TabIndex        =   1
            Top             =   600
            Width           =   2445
            _ExtentX        =   4101
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "PCV No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1135
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   3945
            TabIndex        =   2
            Tag             =   "Transaction Date"
            Top             =   600
            Width           =   1305
            _ExtentX        =   2302
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtRequestedBy 
            Height          =   285
            Left            =   120
            TabIndex        =   4
            Top             =   915
            Width           =   2790
            _ExtentX        =   4710
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Requested by"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1480
         End
         Begin ITGControls.ITGTextBox txtDepartment 
            Height          =   285
            Left            =   120
            TabIndex        =   7
            Top             =   1230
            Width           =   2790
            _ExtentX        =   4710
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Department"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1480
         End
         Begin ITGControls.ITGTextBox txtDeptDesc 
            Height          =   285
            Left            =   3285
            TabIndex        =   9
            TabStop         =   0   'False
            Top             =   1230
            Width           =   4320
            _ExtentX        =   7514
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4260
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtEmpName 
            Height          =   285
            Left            =   3285
            TabIndex        =   6
            TabStop         =   0   'False
            Top             =   915
            Width           =   4320
            _ExtentX        =   7514
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4260
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtPaymentFor 
            Height          =   285
            Left            =   120
            TabIndex        =   12
            Top             =   1860
            Width           =   7485
            _ExtentX        =   12991
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Payment For"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   6175
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtType 
            Height          =   285
            Left            =   6225
            TabIndex        =   16
            Tag             =   "cboType"
            Top             =   600
            Visible         =   0   'False
            Width           =   1140
            _ExtentX        =   1905
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Transaction Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   1080
         End
         Begin ITGControls.ITGTextBox txtTripTicket 
            Height          =   285
            Left            =   120
            TabIndex        =   10
            Top             =   1545
            Width           =   2790
            _ExtentX        =   4710
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Reference No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1480
         End
         Begin VB.Label Label2 
            BackStyle       =   0  'Transparent
            Caption         =   "Date"
            Height          =   270
            Left            =   3405
            TabIndex        =   18
            Top             =   630
            Width           =   630
         End
         Begin VB.Label Label1 
            BackStyle       =   0  'Transparent
            Caption         =   "Type"
            Height          =   270
            Left            =   5565
            TabIndex        =   17
            Top             =   630
            Width           =   630
         End
      End
   End
End
Attribute VB_Name = "frmAPPettyCashAd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'Object variables




Private oPrint As New clsPrinting

'ADO Connection variables

Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection

'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset

'Form mode enumeration
Enum eAPPCAMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eAPPCAMode

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Private strNo As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private Sub cboType_Click()
    If Mode = AddNewEdit Then
        txtType = Trim(cboType)
        If Trim(cboType) = "Van" Then
            cmdPickTripTicket.Enabled = True
        Else
            cmdPickTripTicket.Enabled = False
        End If
    End If
End Sub

Private Sub cboType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cmdPickDeptID_Click()
    If lPickListActive Then Exit Sub
    frmITGPicker.zType = QSecDepartment
    frmITGPicker.Show vbModal
    txtDepartment = frmITGPicker.zCode
    txtDeptDesc = frmITGPicker.zName
    If Trim(txtDeptDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickEmpCode_Click()
    If lPickListActive Then Exit Sub
    frmITGPicker.zType = QEmployee
    frmITGPicker.Show vbModal
    txtRequestedBy = frmITGPicker.zCode
    txtEmpName = frmITGPicker.zName
    If Trim(txtEmpName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickTripTicket_Click()
    If lPickListActive Then Exit Sub
    RepName = Trim(txtRequestedBy)
    frmITGPicker.zType = QTripTicket
    frmITGPicker.Show vbModal
    txtTripTicket = frmITGPicker.zCode
    If Trim(txtTripTicket) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgJE_AfterColUpdate(ByVal ColIndex As Integer)
On Error GoTo ErrorHandler
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgJE.Columns(0).Text) & "'") <> "" Then
                dtgJE.Columns(1).Value = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(dtgJE.Columns(0).Text) & "'")
                dtgJE.Col = 2
            End If
    End Select
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub dtgJE_ButtonClick(ByVal ColIndex As Integer)
If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0 'Account Number
            If lPickListActive Then Exit Sub
            sFilterString = Trim(dtgJE.Columns(0).Text)
            frmITGPickList.mType = Accounts
            frmITGPickList.Show vbModal
            If Trim(frmITGPickList.mCode) = "" Then Exit Sub
            dtgJE.Columns(0).Value = frmITGPickList.mCode & ""
            dtgJE.Columns(1).Value = frmITGPickList.mName & ""
            
    End Select
End Sub

Private Sub dtgJE_Click()
    If Mode = AddNewEdit Then dtgName = dtgJE.Name
End Sub

Private Sub dtgJE_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    End If
    Response = 0
End Sub

Private Sub dtgJE_GotFocus()
    dtgName = dtgJE.Name
End Sub

Private Sub dtgJE_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgJE_KeyPress(KeyAscii As Integer)
On Error GoTo ErrorHandler
If Mode <> AddNewEdit Then Exit Sub
    If rsHeader.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgJE.Col
            Case 0
                TBNewLine
                If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgJE.Columns(0).Text) & "'") <> "" Then
                    dtgJE.Columns(1).Value = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(dtgJE.Columns(0).Text) & "'")
                    dtgJE.Col = 2
                    SendKeys "{Tab}"
                Else
                    dtgJE_ButtonClick (0) 'use button click
                End If
            Case 3
                TBNewLine
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub dtgJE_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgJE.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
    Set FrmName = Me
    FormSetup
    
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'CC07'")
    
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    
    

    Set FrmName = Me
    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
        
    Mode = Find
    txtPettyCashAd.Locked = False
    cmdPickTripTicket.Enabled = False
    
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    
    
    
    
    Set oPrint = Nothing
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing

    Set frmAPPurchaseRequest = Nothing

    lCloseWindow = True
    
End Sub

'Add new record to the recordset
Public Sub TBNew()
On Error GoTo ErrorHandler
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtPettyCashAd.BackColor = &HE0FFFF
    Mode = AddNewEdit

    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connHeader
        OpenNewConnection connDetail
        OpenRecordsetWithCN rsDetail, "*", "PETTY_T", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "PETTY", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If

    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    cboType.ListIndex = -1
    
    'Automatic Approval
    'rsHeader!lApproved = True
    
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    SSTab1.ActiveTab = 0
    txtPettyCashAd.SetFocus
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, lACPrint, True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""
    
    SetDataSource
    SetDataField

ErrorHandler:
    
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
   
    If rsHeader.RecordCount = 0 Then RSZero
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
Dim lNew As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then lBoolean = True
    
    If Not MandatoryOK Then Exit Sub
    
    If rsHeader.Status = adRecNew Then

    End If
    
    
    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    
    cn.CommitTrans
    connHeader.CommitTrans
    connDetail.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, lACPrint, True
    Mode = Normal
    
    
    MsgBox "Record/s successfully saved.", vbInformation, "ComUnion"
    sbRS.Panels(2) = ""
    
    'Audit trail
    UpdateLogFile "Petty Cash Advance", Trim(txtPettyCashAd), IIf(lBoolean, "Inserted", "Updated")

    
ErrHandler:
    
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "ComUnion"
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, lACPrint, True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "ComUnion"
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
On Error GoTo ErrorHandler
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    If rsHeader!lApproved = True Then
        MsgBox "Transaction was already Approved. Edit is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtPettyCashAd.Locked = True
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtPettyCashAd)
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If rsHeader!lApproved = True Then
        MsgBox "Transaction was already Approved. Deletion is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "Purchase Request", Trim(txtPettyCashAd), "Deleted"

    rsHeader.Delete adAffectCurrent
    
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
        
    
    TBPrevRec

    Mode = Normal

    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE PETTY_T WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE PETTY WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtPettyCashAd.Locked = True
    frmITGSearch.Show 'vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
On Error GoTo ErrorHandler
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
            
    OpenNewConnection connHeader
    OpenNewConnection connDetail
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset

    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtPettyCashAd.Locked = False
        txtPettyCashAd.SetFocus
        Exit Sub
    End If
         
    OpenRecordsetWithCN rsHeader, "*", "PETTY", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
    'OpenRecordsetWithCN rsDetail, "*", "PETTY_T", connDetail
                      
    OpenRecordsetWithCN rsDetail, "*", "PETTY_T", connDetail, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM PETTY WHERE " & sTemp & ")")
   
    Set FrmName = Me
    FormLocking True

    If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtPettyCashAd.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, lACPrint, True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
    
  
End If
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgJE.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader

End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader
    
End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader

End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader

End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()
On Error GoTo ErrorHandler
    If rsHeader!cTranNo = "" Then Exit Sub
    If Trim(txtPettyCashAd) = "" Then
        MsgBox "PCV code required.", vbInformation, "ComUnion"
        txtPettyCashAd.SetFocus
        Exit Sub
    End If

    If dtgName = "dtgJE" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cTranNo = Trim(txtPettyCashAd)
        dtgJE.Col = 0
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgJE.SetFocus
    End If
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler

    If dtgName = "dtgJE" Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgJE.Bookmark
        GetChild
        dtgJE.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
    End If
    
    GetChild
    

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
On Error GoTo ErrorHandler
    'MsgBox "Unavailable on " & Me.Name
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Approval is not allowed", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If rsHeader!lApproved = True Then
        MsgBox "Transaction was already approved.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to approve this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    'Audit trail
    UpdateLogFile "Petty Cash Advance", Trim(txtPettyCashAd), "Approved"
    
    rsHeader!lApproved = True
    rsHeader.UpdateBatch adAffectAll
    
    sbRS.Panels(5) = "APPROVED"
    Mode = Normal
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub
    
    'Audit trail
    UpdateLogFile "Petty Cash Advance", Trim(txtPettyCashAd), "Cancelled"

    cn.Execute ("UPDATE PETTY SET lCancelled = 1 WHERE cTranNo = '" & Trim(txtPettyCashAd) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "CANCELLED"
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    cModule = "Purchase_Requisition"
    oPrint.PrintReceipt Trim(txtPettyCashAd)
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgJE.DataSource = rsDetail
    
   
End Sub

'Sets the data field for every bounded controls
Sub SetDataField()
On Error GoTo ErrorHandler
    With rsHeader
        txtPettyCashAd.DataField = !cTranNo
        dtbDate.DataField = !dDate
        txtRequestedBy.DataField = !cRequestedBy
        txtDepartment.DataField = !cDepartment
        txtPaymentFor.DataField = !cPaymentFor
        txtType.DataField = !cType
        txtTripTicket.DataField = !cTripTicket
    End With
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub



Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler

    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount

        If rsHeader.Status <> adRecNew Then
            txtPettyCashAd.Locked = True
        Else
            txtPettyCashAd.Locked = False
        End If

        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If
        
        GetChild
        
        If rsHeader!lCancelled = True Then
            sbRS.Panels(5) = "CANCELLED"
        ElseIf rsHeader!lApproved Then
            sbRS.Panels(5) = "APPROVED"
        Else
            sbRS.Panels(5) = ""
        End If
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtPettyCashAd.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgJE.Refresh
    End If

ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else
        SSTab1.TabEnabled(1) = True
    End If
End Sub

Private Sub txtPettyCashAd_LostFocus()
    'Does Code Already Exist
    If Mode = AddNewEdit Then
        If Trim(txtPettyCashAd) = "" Then
            MsgBox "Empty primary input.", vbInformation, "ComUnion"
            If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
            txtPettyCashAd.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtPettyCashAd = Trim(txtPettyCashAd)
            If IDExisting(rsHeader, "cTranNo", "PETTY", Trim(rsHeader!cTranNo)) Then
                MsgBox "PCV No. already exist.", vbInformation, "ComUnion"
                If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
                txtPettyCashAd.SetFocus
            End If
        End If
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean
    
    MandatoryOK = True

    If Trim(txtPettyCashAd) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Requisition Number' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtPettyCashAd.SetFocus
        Exit Function
    End If
    
'    If rsHeader.Status = adRecNew And lSystemGeneratedPR = False Then
'        If IDExisting(rsHeader, "cPRNo", "REQUISITION", Trim(rsHeader!cPRNo)) Then
'            MandatoryOK = False
'            MsgBox "Requisition No. already exist.", vbInformation, "ComUnion"
'            txtPettyCashAd.SetFocus
'            Exit Function
'        End If
'    End If

    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtRequestedBy) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Requested by' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtRequestedBy.SetFocus
        Exit Function
    ElseIf Trim(txtDepartment) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Department' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtDepartment.SetFocus
        Exit Function
    End If
    
    GetChild
    
    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, "ComUnion"
        dtgJE.SetFocus
        Exit Function
    End If
    
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cAcctNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cAcctNo) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop

    GetChild

    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, "ComUnion"
        MandatoryOK = False
        Exit Function
    End If

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgJE.DataSource = Nothing
    dtgJE.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtPettyCashAd.Locked = False
    txtPettyCashAd.SetFocus
    
    Mode = Find
    
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cmdPickEmpCode.Enabled = lEnable
    cmdPickDeptID.Enabled = lEnable
    cboType.Enabled = lEnable
End Sub


'Gets initital item values
Private Sub GetInitialItemValues(RefRS As Recordset)
On Error GoTo ErrorHandler
    RefRS!cItemType = "Trade"
    RefRS!cDesc = Trim(GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
    RefRS!cUnit = Trim(GetValueFrTable("cUnit", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Gets initital asset values
Private Sub GetInitialAssetValues(RefRS As Recordset)
On Error GoTo ErrorHandler
    RefRS!cItemType = "Asset"
    RefRS!cDesc = Trim(GetValueFrTable("cDesc", "ASSET", "cAssetNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
    RefRS!cUnit = "Unit" 'Trim(GetValueFrTable("cUnit", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Gets initital asset values
Private Sub GetInitialSupplyValues(RefRS As Recordset)
    RefRS!cItemType = "Supply"
    RefRS!cDesc = Trim(GetValueFrTable("cDesc", "SUPPLY", "cSupplyNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
    RefRS!cUnit = Trim(GetValueFrTable("cUnit", "SUPPLY", "cSupplyNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtPettyCashAd.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTranNo LIKE '" & Trim$(txtPettyCashAd.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(txtRequestedBy.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cRequestedBy LIKE '" & Trim$(txtRequestedBy.Text) & "%'"
    End If
    
    If Trim$(txtDepartment.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cDepartment LIKE '" & Trim$(txtDepartment.Text) & "%'"
    End If
    
    If Trim$(txtType.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cType LIKE '" & Trim$(txtType.Text) & "%'"
    End If
    
    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function

Private Sub txtDepartment_Change()
    txtDeptDesc = ""
    txtDeptDesc = GetValueFrTable("Description", "SEC_DEPARTMENT", "DeptID = '" & Trim(txtDepartment) & "'", True)
End Sub

Private Sub txtDepartment_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtDeptDesc) = "" And Trim(txtDepartment) <> "" Then cmdPickDeptID_Click
End Sub

Private Sub txtRequestedBy_Change()
    txtEmpName = ""
    txtEmpName = GetValueFrTable("cEmpName", "EMPLOYEE", "cEmpCode = '" & Trim(txtRequestedBy) & "'")
End Sub

Private Sub txtRequestedBy_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtEmpName) = "" And Trim(txtRequestedBy) <> "" Then cmdPickEmpCode_Click
End Sub

'Form list to grid
Public Sub AddDetailsFromList()
    
End Sub

'System genereted number
Sub GetCtrlNo()
Dim lCtrlNoOK As Boolean

    strNo = Trim(GetValueFrTable("cValue", "PARAMETER_USER", "cType = 'PRNO' "))
    
    Do Until lCtrlNoOK
        If IDExisting(rsHeader, "cPRNo", "REQUISITION", Left(strNo, 5) + Format(CStr((CInt(Right(strNo, 4)) + 1)), "0000")) Then
            strNo = Left(strNo, 5) + Format(CStr((CInt(Right(strNo, 4)) + 1)), "0000")
        Else
            lCtrlNoOK = True
        End If
    Loop
    
    If Mid(strNo, 4, 2) <> Format(Date, "yy") Then
        txtPettyCashAd = Format(1, "0000")
        strNo = "PR-" + Format(Date, "yy") + "0000"
    Else
        txtPettyCashAd = Format(Right(strNo, 4) + 1, "0000")
    End If
    txtPettyCashAd = "PR-" + Format(Date, "yy") + Trim(txtPettyCashAd)
End Sub

'Check system generated number before saving
Function CheckCtrlNo() As Boolean

Dim lCtrlNoOK As Boolean
Dim strNewNo As String
Dim strNewPRNo As String
Dim sTrap

On Error GoTo TheSource

    CheckCtrlNo = False
    
    If IDExisting(rsHeader, "cPRNo", "REQUISITION", rsHeader!cPRNo) Then
        sTrap = Left(txtPettyCashAd, 5) & (Format(Right(txtPettyCashAd, 4) - 1, "0000"))
        
        strNewNo = Trim(GetValueFrTable("cValue", "PARAMETER_USER", "cType = 'PRNO' "))
        
        Do Until lCtrlNoOK
            If IDExisting(rsHeader, "cPRNo", "REQUISITION", Left(strNewNo, 5) + Format(CStr((CInt(Right(strNewNo, 4)) + 1)), "0000")) Then
                strNewNo = Left(strNewNo, 5) + Format(CStr((CInt(Right(strNewNo, 4)) + 1)), "0000")
            Else
                lCtrlNoOK = True
            End If
        Loop
        
        If Mid(strNewNo, 4, 2) <> Format(Date, "yy") Then
            strNewPRNo = Format(1, "0000")
            strNewNo = "PR-" + Format(Date, "yy") + "0000"
        Else
            strNewPRNo = Format(Right(strNewNo, 4) + 1, "0000")
        End If
        strNewPRNo = "PR-" + Format(Date, "yy") + Trim(strNewPRNo)
        
        GetChild
        
        rsHeader!cPRNo = strNewPRNo
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Do Until rsDetail.EOF
            rsDetail!cPRNo = strNewPRNo
            rsDetail.MoveNext
        Loop
        
        GetChild
        
        strNo = strNewNo
    End If
    
    CheckCtrlNo = True
    
TheSource:
    If Not CheckCtrlNo Then
        If MsgBox("Record cannot be updated. Transaction number already exists. " & vbCr & _
                "Current transaction number may have been used by other user/s since last read." & vbCr & _
                "Do you want to assign another number?", vbYesNo + vbInformation, "ComUnion") = vbYes Then
            frmChangeTranNo.mType = Change_PRNo
            frmChangeTranNo.Show vbModal
        Else
            MsgBox "Transaction will be undone.", vbInformation, "ComUnion"
            TBUndoAll
        End If
    End If
End Function

'Update system generated number
Sub UpdateCtrlNo()
On Error GoTo TheSource
   
    If (Left(txtPettyCashAd, 5) & (Format(Right(txtPettyCashAd, 4) - 1, "0000"))) <> (strNo) Then Exit Sub
    sSQL = "UPDATE PARAMETER_USER SET cValue = '" & Trim(txtPettyCashAd) & "' WHERE cType = 'PRNO' AND cCompanyID = '" & COID & "'"
    cn.Execute sSQL

TheSource:
    Exit Sub
End Sub

'Change Transaction Number
Sub ChangeTranNo(strTranNo As String)
    GetChild
    
    rsHeader!cPRNo = strTranNo
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        rsDetail!cPRNo = strTranNo
        rsDetail.MoveNext
    Loop
    
    GetChild
End Sub

'Clear Data Grid
Private Sub ClearDataGrid()
    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    GetChild
End Sub

'Public Sub ShowForm(sTranNo As String)
'On Error GoTo ErrorHandler
'    If Mode = Find Then
'
'        OpenNewConnection connHeader
'        OpenNewConnection connDetail
'
'        Set rsHeader = Nothing
'        Set rsDetail = Nothing
'        Set rsHeader = New ADODB.Recordset
'        Set rsDetail = New ADODB.Recordset
'
'        OpenRecordsetWithCN rsDetail, "*", "REQUISITION_T", connDetail, "WHERE cPRNo = '" & Trim(sTranNo) & "'"
'        OpenRecordsetWithCN rsHeader, "*", "REQUISITION", connHeader, "WHERE cPRNo = '" & Trim(sTranNo) & "'"
'
'        Set FrmName = Me
'        FormLocking True
'
'        If rsHeader.RecordCount = 0 Then
'            FormWaitHide
'            MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
'            RSZero
'            FormSearch True
'            SearchObj True
'            Mode = Find
'            Exit Sub
'        End If
'            SetDataSource
'            SetDataField
'            txtPettyCashAd.BackColor = &HE0FFFF
'            Mode = Normal
'            oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True, True
'
'    End If
'ErrorHandler:
'    If err.Number <> 0 Then
'        MsgBox err.Description, vbInformation, "ComUnion"
'    End If
'End Sub

Private Sub txtTripTicket_Change()
On Error GoTo ErrorHandler
    If Mode <> AddNewEdit Then Exit Sub
    If cmdPickTripTicket.Enabled = False Then Exit Sub
    If GetValueFrTable("cTranNo", "TRIPTICKET", "cTranNo = '" & Trim(txtTripTicket) & "' AND cDriver = '" & Trim(txtRequestedBy) & "'") = "" Then Exit Sub
    If Trim(txtTripTicket) <> "" Then

        sSQL = "SELECT nAllowance FROM TripTicket " & _
                "WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(txtTripTicket) & "' " & _
                "GROUP BY nAllowance"
        Set rs = New Recordset
        rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        Do While Not rs.EOF
            With rsDetail
                .AddNew
                !cCompanyID = COID
                !cTranNo = Trim(rsHeader!cTranNo)
                !cAcctNo = GetValueFrTable("cAdvAccount", "EMPLOYEE", "cEmpCode = '" & Trim(txtRequestedBy) & "'")
                !cTitle = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(!cAcctNo) & "'")
                !nDebit = 0
                !nCredit = rs!nAllowance

                .AddNew
                !cCompanyID = COID
                !cTranNo = Trim(rsHeader!cTranNo)
                !cAcctNo = GetValueFrTable("cValue", "System_Option", "cCode = 'DEF_CASH'")
                !cTitle = GetValueFrTable("cTitle", "Account", "cAcctNo = '" & Trim(!cAcctNo) & "'")
                !nDebit = rs!nAllowance
                !nCredit = 0
            End With
            rs.MoveNext
        Loop

        Set rs = Nothing
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
    End If
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub txtType_Change()
    If Trim(txtType) <> "" Or txtType <> vbNullString Then
        cboType = Trim(txtType)
    Else
        cboType.ListIndex = -1
    End If
End Sub


